#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int nums[] = {3,2,1};
    int size = sizeof(nums) / sizeof(nums[0]);
    int index1 = -1;
    int index2 = -1;
    int count = 2;
    for (int i = 0; i < size - 1; i++)
    {
        if (nums[i] > nums[i + 1])
        {
            if (count == 2) {
                index2 = i;
                count--;
            }
            else if (count == 1) {
                index2 = i + 1;
                count--;
            }
            if (index1 == -1) {
                index1 = i;
            }
            else {
                break;
            }
        }
    }
    if (count == 1) {
        index2 = index1 + 1;
    }
    int tmp = nums[index1];
    nums[index1] = nums[index2];
    nums[index2] = tmp;
}